package com.bw.medical.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bw.medical.dao.TbDockerLevelDao;
import com.bw.medical.entity.TbDiagnoseEntity;
import com.bw.medical.vo.InquiryVo;
import com.bw.medical.vo.Pojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bw.medical.entity.TbDockerLevelEntity;
import com.bw.medical.service.TbDockerLevelService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 医师表 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-14 18:10:33
 */
@RestController
@RequestMapping("medical/tbdockerlevel")
public class TbDockerLevelController {
    @Autowired
    private TbDockerLevelService tbDockerLevelService;
    @Autowired
    private TbDockerLevelDao tbDockerLevelDao;
    /**
     * 医生列表
     */
    @RequestMapping("/lists")
    public R list(@RequestParam Map<String, Object> params){
        IPage<TbDockerLevelEntity> page = tbDockerLevelService.getLists(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R lists(@RequestParam Map<String, Object> params){
        IPage<TbDiagnoseEntity> page=tbDockerLevelService.getLista(params);
        PageUtils pageUtils = new PageUtils(page.getRecords(), (int) page.getTotal(), (int) page.getSize(), (int) page.getPages());
        return R.ok().put("page", pageUtils);
    }
    /**
     * 快速问诊列表
     */
    @PostMapping("/doclist")
    public R doclist(@RequestBody InquiryVo vo,
                     @RequestParam(value = "page",defaultValue = "1")Integer page,
                     @RequestParam(value = "limit",defaultValue = "2")Integer limit){
        IPage<InquiryVo> list=tbDockerLevelService.getDoclist(vo,page,limit);
        PageUtils pageUtils = new PageUtils(list.getRecords(), (int) list.getTotal(), (int) list.getSize(), (int) list.getPages());
        return  R.ok().put("list",pageUtils);
    }
    /**
     * 信息
     */
    @RequestMapping("/userId")
    public Integer userId(@RequestParam("userId") Integer userId){
        TbDockerLevelEntity userId1 = tbDockerLevelDao.selectOne(new QueryWrapper<TbDockerLevelEntity>().eq("user_id", userId));
        return userId1.getDocterId();
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TbDockerLevelEntity tbDockerLevel){
		tbDockerLevelService.save(tbDockerLevel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TbDockerLevelEntity tbDockerLevel){
		tbDockerLevelService.updateById(tbDockerLevel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] docterIds){
		tbDockerLevelService.removeByIds(Arrays.asList(docterIds));

        return R.ok();
    }

}
